%%%----------------------------------------------------------------------
%%% File    : erml_scan.xrl
%%% Author  : Stuart Jackson <sjackson@simpleenigma.com> [http://www.simpleenigma.com]
%%% Purpose : Erlang Markup Language token scanner
%%% Created : 2007-01-14
%%% Updated : 2007-01-17
%%%----------------------------------------------------------------------

Definitions.
O    = [0-7]
D	 = [0-9]
H	 = [0-9a-fA-F]
U	 = [A-Z]
L    = [a-z]
CRLF = [\r\n]
WS   = ([\s\t])
END  = [\000]
A    = ({U}|{L}|{D})
LD   = ({L}|{D})
P    = ({A}|{WS})
N    = {D}+
ATOM = [=\/:.]

CLOSE = >
COMMAND  = <erml{LD}+{CLOSE}*
STRING  = "(\\\^.|\\.|[^"])*"
ARG = ({LD}|[:-])+{WS}*={WS}*{STRING}
BEGIN = (<{A}+|<!{A}+)
END = />
TAG  = {BEGIN}{CLOSE}*
ENDC = </erml({L}|{D})+>
ENDT = </({L}|{D})+>
VAR = %{LD}+%

TEXT = ({ATOM}|{A})+

Rules.

{ARG} : {token,{arg,TokenChars}}.

{VAR} : {token,{variable,TokenChars}}.
{COMMAND} : {token,{command,TokenChars}}.
{ENDC} : {token,{endcommand,TokenChars}}.
{TAG} : {token,{tag,TokenChars}}.
{END} : {token,{endtag,TokenChars}}.
{ENDT} : {token,{endtag,TokenChars}}.
{CLOSE} : {token,{closetag,list_to_atom(TokenChars)}}.

{TEXT} : {token,{string,TokenChars}}.


{CRLF}+ : skip_token.
{WS}+   : skip_token.
{END}{WS}* : {end_token,{'$end'}}.

Erlang code.



